<!--用户管理-->
<template>
  <section class="webview fixHeight">
    <el-scrollbar style="height:100%">
      <el-tabs>
        <el-tab-pane label="经纪人" lazy>
          <Agent />
        </el-tab-pane>
        <el-tab-pane label="开发商" lazy>
          <Developers />
        </el-tab-pane>
        <el-tab-pane label="房产公司" lazy>
          <HouseCompany />
        </el-tab-pane>
        <el-tab-pane label="会员" lazy>
          <Member></Member>
        </el-tab-pane> 
		 <el-tab-pane label="设计师" lazy>
          <designer></designer>
		 </el-tab-pane>
		 <el-tab-pane label="家居顾问" lazy>
          <listHomeHold></listHomeHold>
		 </el-tab-pane> 
		 <el-tab-pane label="家装顾问" lazy>
          <decoration></decoration>
		 </el-tab-pane>
      </el-tabs>
    </el-scrollbar>
  </section>
</template>
<script>
import Agent from './components/agent'
import HouseCompany from './components/houseCompany'
import Developers from './components/developers'
import Member from './components/member'
import listHomeHold from './components/listHomeHold'
import decoration from './components/decoration'
import designer from './components/designer'
export default {
  components: {
    Agent,
    HouseCompany,
    Developers,
    designer,
    listHomeHold,
    decoration,
    Member
  },
  data() {
    return {
      pagination: {
        pageSize: 10,
        page: 1,
        total: 0
      },
      detail: {
        name: '',
        status: null
      },
      statusOptions: [
        {
          value: null,
          label: '全部'
        },
        {
          value: 1,
          label: '正常'
        },
        {
          value: 0,
          label: '禁用'
        }],
      ids: []
    }
  },
  methods: {
    editStatusSingle(type, id) {
      if (type == 1) {
        // 启用
        updateHospitalStatus({
          ids: [id],
          status: 1
        }).then(data => {
          Is.tip('启用成功')
          this.getList()
        })
      }
    },
    editStatusSingles(type) {
      if (Is.empty(this.ids)) {
        Is.tip('未选择编辑项')
        return false
      }
      if (type == 1) {
        // 启用
        updateHospitalStatus({
          ids: this.ids,
          status: 1
        }).then(data => {
          Is.tip('启用成功')
          this.getList()
        })
      }
      if (type == 0) {
        // 禁用
        updateHospitalStatus({
          ids: this.ids,
          status: 0
        }).then(data => {
          Is.tip('禁用成功')
          this.getList()
        })
      }
    },
    reset() {
      this.detail = {
        name: '',
        status: null
      }
      this.pagination = {
        pageSize: 10,
        page: 1,
        total: 0
      }
      this.getList()
    },
    getList() {
      const params = {
        name: this.detail.name,
        status: this.detail.status,
        page: this.pagination.page,
        pageSize: this.pagination.pageSize
      }
      hospitalList(params).then(data => {
        this.list = data.respPageBean.data
        this.pagination.total = data.data.total
        // this.list = data
      })
    },
    handleSelectAll(selection) {
      this.ids = []
      if (selection.length > 0) {
        selection.forEach(item => {
          this.ids.push(item.id)
        })
      }
    },
    handleCurrentChange(val) {
      // 重置当前页码
      this.pagination.page = val
      this.getList()
    },
    handleSelectionChange(selection) {
      this.ids = []
      if (selection.length > 0) {
        selection.forEach(item => {
          this.ids.push(item.id)
        })
      }
    },
    // 多选删除
    toDels() {
      if (Is.empty(this.ids)) {
        Is.tip('未选择删除项')
        return false
      }
      this.$confirm('确认删除？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        delHospital(
          this.ids
        ).then(data => {
          Is.tip('删除成功', 1500, 'success')
          if (this.list.length === this.ids.length && this.pagination.page > 1) {
            this.pagination.page--
          }
          this.getList()
        })
      })
    },
    // 单选删除
    toDel(id) {
      this.$confirm('确认删除？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        delHospital(
          [id]
        ).then(data => {
          Is.tip('删除成功', 1500, 'success')
          if (this.list.length === 1 && this.pagination.page > 1) {
            this.pagination.page--
          }
          this.getList()
        })
      }).catch((e) => {

      })
    }
  }}
</script>
